from selenium.webdriver.common.by import By
from pages.base_page import Page


class WrapUpPage(Page):
    ele_title = (By.ID, u'page-wrapUpSurvey-title')
    ele_campaign_select = (By.XPATH, u'(//div[@role="button" and contains(@class,"MuiInputBase-input")])[2]')
    ele_time_range = (By.XPATH, u'(//div[contains(@class,"MuiInputBase-input")])[1]')
    ele_completion_by_time = (By.XPATH, u'//span[text()="Completion By Time"]')
    ele_completion_by_department = (By.XPATH, u'//span[text()="Completion By Department"]')
    ele_completion_by_agent = (By.XPATH, u'//span[text()="Completion By Agent"]')

    # 无此feature的图片
    ele_no_wrap_up_image = (By.XPATH, u'//h3[text()="Feature Introduction"]//../div/img')
    ele_unlock_this_feature = (By.XPATH, u'//button/span[text()="Unlock This Feature"]')

    def __init__(self, driver, url, site_id):
        Page.__init__(self, driver, url)
        self.site_id = site_id
        self.url = url

    def wrapup_page_eles_check_when_has_wrapup_feature(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_campaign_select).is_enabled()
        self.find_element(*self.ele_time_range).is_enabled()
        self.find_element(*self.ele_completion_by_time).is_enabled()
        self.find_element(*self.ele_completion_by_department).is_enabled()
        self.find_element(*self.ele_completion_by_agent).is_enabled()

    def wrapup_page_eles_check_when_no_wrapup_feature(self):
        self.find_element(*self.ele_title).is_enabled()
        self.find_element(*self.ele_no_wrap_up_image).is_enabled()
        self.find_element(*self.ele_unlock_this_feature).is_enabled()
